﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mail_group.aspx.cs" Inherits="backmanage_mailsystem_mail_group" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>分组管理</title>
    <script type="text/javascript" src="../js/jquery-1.6.1.js"></script>
    <script type="text/javascript">
     $(function(){
       var groupid,state;
       function grouplist()
       {
         $.post("../API/A_Emailgroup.aspx",{"edit":"grouplist"},function(msg){$("table tbody").html(msg);},"html");
       }
       function groupadd()
       {
             var name=$("#name").val();
             if(name.length==0)
             {
               alert("请填写分组名称!");
               return false;
             }
             if(state=="add")
             {
                 $.post("../API/A_Emailgroup.aspx",{"edit":"groupadd","name":name},function(msg){grouplist();$("#name").val("");},"html");
             }
             else if(state=="update"){
                 $.post("../API/A_Emailgroup.aspx",{"edit":"groupupdate","id":groupid,"name":name},function(msg){grouplist();state="add";$("#name").val("");},"html");
             }
       }
       function groupupdate(e)
       {
          var type=$(e).attr("title");
          groupid=$(e).parent().parent().attr("id");
          if(type=="update")
          {
             $.post("../API/A_Emailgroup.aspx",{"edit":"groupinfo","id":groupid},function(data){$("#name").val(data.name);},"json")
             state="update";
          }
          else if(type=="delete")
          {
             $.post("../API/A_Emailgroup.aspx",{"edit":"groupdelete","id":groupid},function(msg){grouplist();},"html")
          }
       }
       $(document).ready(function(){
          grouplist();
          $("#sumbit").live("click",function(){groupadd();});
          $("table a").live("click",function(){groupupdate(this)});
       });
     });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="text" id="name" />
    <input type="button" id="sumbit" value="提交" />
    </div>
    <div>
      <table>
        <thead>
          <tr>
            <td>分组名称</td>
            <td>添加人</td>
            <td>操作</td>
          </tr>
        </thead>
        <tbody>
        </tbody>
        <tfoot>
        </tfoot>
      </table>
    </div>
    </form>
</body>
</html>
